/*
 * Visualizador.java
 *
 * Created on 11 de Julho de 2007, 15:12
 */
package br.com.cpqd.ssar.posprocessamento;

import java.awt.Dimension;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;

/**
 *
 * @author  acer
 */
public class Visualizador extends javax.swing.JFrame {

    /** Creates new form Visualizador */
    public Visualizador(String name) {

        initComponents();
        setTitle("Pós Processamento - " + name);
        this.name = name;
        inicializeGLCanvas();
    }

    /** Return canvas attribute*/
    public GLCanvas getGLCanvas() {
        return canvas;
    }

    /** Inicialize Canvas Area */
    public void inicializeGLCanvas() {

        if (r.getGridFFT()) {
            jCkVisivel.setSelected(true);
        } else {
            jCkVisivel.setSelected(false);
        }
        canvas = new GLCanvas();
        canvas.setPreferredSize(new Dimension(300, 300));
//        GLAutoDrawable a;
        r.setGLCanvas(canvas);
        canvas.addGLEventListener(r);
//        jMenuArquivo.getPopupMenu().setLightWeightPopupEnabled(false);
//        jMenuEdit.getPopupMenu().setLightWeightPopupEnabled(false);
        // Adiciona a variavel canvas ao Panel
        jScrollPane1.setViewportView(canvas);
        canvas.display();

    }

    @Override
    public String toString() {
        return name;

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDialogConfigGrade = new javax.swing.JDialog();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jButtonVisualizarGrade = new javax.swing.JButton();
        jSqtdY = new javax.swing.JSpinner();
        jSqtdX = new javax.swing.JSpinner();
        jButtonCancelarGrade = new javax.swing.JButton();
        jButtonConfirmarGrade = new javax.swing.JButton();
        jCkVisivel = new javax.swing.JCheckBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        jSeparator1 = new javax.swing.JSeparator();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTAStatus = new javax.swing.JTextArea();
        jToolBar1 = new javax.swing.JToolBar();
        jButtonSaveImg = new javax.swing.JButton();
        jButtonLupaMais = new javax.swing.JButton();
        jButtonLupaMenos = new javax.swing.JButton();
        jButtonShowGrid = new javax.swing.JButton();
        jButtonRotYRight = new javax.swing.JButton();
        jButtonRotYLeft = new javax.swing.JButton();
        jButtonRotXUp = new javax.swing.JButton();
        jButtonRotXDown = new javax.swing.JButton();
        jButtonRotZmenos = new javax.swing.JButton();
        jButtonRotZmais = new javax.swing.JButton();
        jButtonMoveLeft = new javax.swing.JButton();
        jButtonMoveUp = new javax.swing.JButton();
        jButtonMoveDown = new javax.swing.JButton();
        jButtonMoveRight = new javax.swing.JButton();

        jDialogConfigGrade.setTitle("Configurar Grade");
        jDialogConfigGrade.setAlwaysOnTop(true);
        jDialogConfigGrade.setBounds(new java.awt.Rectangle(250, 500, 350, 170));
        jDialogConfigGrade.setMinimumSize(null);
        jDialogConfigGrade.setName("dialogConfigGrade"); // NOI18N
        jDialogConfigGrade.setResizable(false);

        jLabel2.setText("Qtd Grade Eixo X:");

        jLabel4.setText("Qtd Grade Eixo Y:");

        jButtonVisualizarGrade.setText("Visualizar");
        jButtonVisualizarGrade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonVisualizarGradeActionPerformed(evt);
            }
        });

        jButtonCancelarGrade.setText("Cancelar");
        jButtonCancelarGrade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCancelarGradeActionPerformed(evt);
            }
        });

        jButtonConfirmarGrade.setText("Confirmar");
        jButtonConfirmarGrade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonConfirmarGradeActionPerformed(evt);
            }
        });

        jCkVisivel.setText("Visível");
        jCkVisivel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCkVisivelActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jDialogConfigGradeLayout = new org.jdesktop.layout.GroupLayout(jDialogConfigGrade.getContentPane());
        jDialogConfigGrade.getContentPane().setLayout(jDialogConfigGradeLayout);
        jDialogConfigGradeLayout.setHorizontalGroup(
            jDialogConfigGradeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jDialogConfigGradeLayout.createSequentialGroup()
                .addContainerGap()
                .add(jDialogConfigGradeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jDialogConfigGradeLayout.createSequentialGroup()
                        .add(jButtonCancelarGrade)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jButtonVisualizarGrade))
                    .add(jDialogConfigGradeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                        .add(jDialogConfigGradeLayout.createSequentialGroup()
                            .add(jLabel2)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jSqtdX, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 47, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(jDialogConfigGradeLayout.createSequentialGroup()
                            .add(jLabel4)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jSqtdY))))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jDialogConfigGradeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jCkVisivel)
                    .add(jButtonConfirmarGrade))
                .addContainerGap(59, Short.MAX_VALUE))
        );
        jDialogConfigGradeLayout.setVerticalGroup(
            jDialogConfigGradeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jDialogConfigGradeLayout.createSequentialGroup()
                .addContainerGap()
                .add(jDialogConfigGradeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel2)
                    .add(jSqtdX, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jDialogConfigGradeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel4)
                    .add(jSqtdY, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jCkVisivel))
                .add(22, 22, 22)
                .add(jDialogConfigGradeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButtonVisualizarGrade)
                    .add(jButtonCancelarGrade)
                    .add(jButtonConfirmarGrade))
                .addContainerGap(22, Short.MAX_VALUE))
        );

        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setLocationByPlatform(true);

        jScrollPane1.setAutoscrolls(true);

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jTAStatus.setColumns(20);
        jTAStatus.setEditable(false);
        jTAStatus.setRows(5);
        jScrollPane2.setViewportView(jTAStatus);

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 707, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE)
                .addContainerGap())
        );

        jButtonSaveImg.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/cpqd/ssar/gerenciador/gui/recursos/disk.png"))); // NOI18N
        jButtonSaveImg.setToolTipText("Exportar Imagem");
        jButtonSaveImg.setEnabled(false);
        jButtonSaveImg.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSaveImgActionPerformed(evt);
            }
        });
        jToolBar1.add(jButtonSaveImg);

        jButtonLupaMais.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/cpqd/ssar/gerenciador/gui/recursos/zoom_in.gif"))); // NOI18N
        jButtonLupaMais.setToolTipText("Zoom +");
        jButtonLupaMais.setEnabled(false);
        jButtonLupaMais.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aproximarListener(evt);
            }
        });
        jToolBar1.add(jButtonLupaMais);

        jButtonLupaMenos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/cpqd/ssar/gerenciador/gui/recursos/zoom_out.gif"))); // NOI18N
        jButtonLupaMenos.setToolTipText("Zoom -");
        jButtonLupaMenos.setEnabled(false);
        jButtonLupaMenos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                afastarListener(evt);
            }
        });
        jToolBar1.add(jButtonLupaMenos);

        jButtonShowGrid.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/cpqd/ssar/gerenciador/gui/recursos/showGrid.jpg"))); // NOI18N
        jButtonShowGrid.setToolTipText("Mostrar Grade");
        jButtonShowGrid.setEnabled(false);
        jButtonShowGrid.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonShowGridActionPerformed(evt);
            }
        });
        jToolBar1.add(jButtonShowGrid);

        jButtonRotYRight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/cpqd/ssar/gerenciador/gui/recursos/rotYmais.gif"))); // NOI18N
        jButtonRotYRight.setToolTipText("Rotacionar Eixo Y");
        jButtonRotYRight.setEnabled(false);
        jButtonRotYRight.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                girarYPositivoListener(evt);
            }
        });
        jToolBar1.add(jButtonRotYRight);

        jButtonRotYLeft.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/cpqd/ssar/gerenciador/gui/recursos/rotYmenos.gif"))); // NOI18N
        jButtonRotYLeft.setToolTipText("Rotacionar Eixo Y");
        jButtonRotYLeft.setEnabled(false);
        jButtonRotYLeft.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                girarYNegativoListener(evt);
            }
        });
        jToolBar1.add(jButtonRotYLeft);

        jButtonRotXUp.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/cpqd/ssar/gerenciador/gui/recursos/rot_up.gif"))); // NOI18N
        jButtonRotXUp.setToolTipText("Rotacionar Eixo X");
        jButtonRotXUp.setEnabled(false);
        jButtonRotXUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                girarXPositivoListener(evt);
            }
        });
        jToolBar1.add(jButtonRotXUp);

        jButtonRotXDown.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/cpqd/ssar/gerenciador/gui/recursos/rot_down.gif"))); // NOI18N
        jButtonRotXDown.setToolTipText("Rotacionar Eixo X");
        jButtonRotXDown.setEnabled(false);
        jButtonRotXDown.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                girarXNegativoListener(evt);
            }
        });
        jToolBar1.add(jButtonRotXDown);

        jButtonRotZmenos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/cpqd/ssar/gerenciador/gui/recursos/rotZmais.gif"))); // NOI18N
        jButtonRotZmenos.setToolTipText("Rotacionar Eixo Z");
        jButtonRotZmenos.setEnabled(false);
        jButtonRotZmenos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                girarZNegativoListener(evt);
            }
        });
        jToolBar1.add(jButtonRotZmenos);

        jButtonRotZmais.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/cpqd/ssar/gerenciador/gui/recursos/rotYmenos.gif"))); // NOI18N
        jButtonRotZmais.setToolTipText("Rotacionar Eixo Z");
        jButtonRotZmais.setEnabled(false);
        jButtonRotZmais.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                girarZPositivoListener(evt);
            }
        });
        jToolBar1.add(jButtonRotZmais);

        jButtonMoveLeft.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/cpqd/ssar/gerenciador/gui/recursos/moveLeft.gif"))); // NOI18N
        jButtonMoveLeft.setEnabled(false);
        jButtonMoveLeft.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonMoveLeftActionPerformed(evt);
            }
        });
        jToolBar1.add(jButtonMoveLeft);

        jButtonMoveUp.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/cpqd/ssar/gerenciador/gui/recursos/moveUp.gif"))); // NOI18N
        jButtonMoveUp.setEnabled(false);
        jButtonMoveUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonMoveUpActionPerformed(evt);
            }
        });
        jToolBar1.add(jButtonMoveUp);

        jButtonMoveDown.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/cpqd/ssar/gerenciador/gui/recursos/moveDown.gif"))); // NOI18N
        jButtonMoveDown.setEnabled(false);
        jButtonMoveDown.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonMoveDownActionPerformed(evt);
            }
        });
        jToolBar1.add(jButtonMoveDown);

        jButtonMoveRight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/cpqd/ssar/gerenciador/gui/recursos/moveRight.gif"))); // NOI18N
        jButtonMoveRight.setEnabled(false);
        jButtonMoveRight.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonMoveRightActionPerformed(evt);
            }
        });
        jToolBar1.add(jButtonMoveRight);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .add(jSeparator1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 741, Short.MAX_VALUE)
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 731, Short.MAX_VALUE))
                    .add(jToolBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(jToolBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 31, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 12, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonConfirmarGradeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConfirmarGradeActionPerformed
// TODO adicione seu c�digo de manipula��o aqui:
        int qtdX = Integer.valueOf(jSqtdX.getValue().toString());
        int qtdY = Integer.valueOf(jSqtdY.getValue().toString());
        r.setQtdGrade(qtdX, qtdY);
        canvas.display();
        jDialogConfigGrade.setVisible(false);
    }//GEN-LAST:event_jButtonConfirmarGradeActionPerformed

    private void jButtonCancelarGradeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelarGradeActionPerformed
// TODO adicione seu c�digo de manipula��o aqui:
        r.setQtdGrade(qtdXantes, qtdYantes);
        canvas.display();
        jDialogConfigGrade.setVisible(false);

    }//GEN-LAST:event_jButtonCancelarGradeActionPerformed

    private void jButtonVisualizarGradeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVisualizarGradeActionPerformed
// TODO adicione seu c�digo de manipula��o aqui:
        int qtdX = Integer.valueOf(jSqtdX.getValue().toString());
        int qtdY = Integer.valueOf(jSqtdY.getValue().toString());
        r.setQtdGrade(qtdX, qtdY);
        canvas.display();
    }//GEN-LAST:event_jButtonVisualizarGradeActionPerformed

    private void jButtonShowGridActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonShowGridActionPerformed
// TODO adicione seu c�digo de manipula��o aqui:
        if (jDialogConfigGrade.isVisible()) {
            jDialogConfigGrade.setVisible(false);
        } else {
            jDialogConfigGrade.setVisible(true);
            qtdXantes = (int) r.getQtdGradeX();
            qtdYantes = (int) r.getQtdGradeY();
            jSqtdX.setValue((Object) qtdXantes);
            jSqtdY.setValue((Object) qtdYantes);
        }
    }//GEN-LAST:event_jButtonShowGridActionPerformed

    private void jButtonSaveImgActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSaveImgActionPerformed

        ImportadorArquivo arq = new ImportadorArquivo();
        if (arq.getName() == null) {
            this.dispose();
        } else {
            r.setFileName(arq.getName());
            r.setStatusSave(true);
            canvas.display();
            r.setStatusSave(false);
            canvas.display();
            jTAStatus.append("\n Arquivo: " + arq.getName() + " salvo com sucesso.");
        }
    //jMenuItemSalvarGrafico.setEnabled(false);
    }//GEN-LAST:event_jButtonSaveImgActionPerformed

    private void jButtonMoveDownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMoveDownActionPerformed
// TODO adicione seu c�digo de manipula��o aqui:
        r.moveDown();
        canvas.display();
    }//GEN-LAST:event_jButtonMoveDownActionPerformed

    private void jButtonMoveUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMoveUpActionPerformed
// TODO adicione seu c�digo de manipula��o aqui:
        r.moveUp();
        canvas.display();
    }//GEN-LAST:event_jButtonMoveUpActionPerformed

    private void jButtonMoveRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMoveRightActionPerformed
// TODO adicione seu c�digo de manipula��o aqui:
        r.moveRight();
        canvas.display();
    }//GEN-LAST:event_jButtonMoveRightActionPerformed

    private void jButtonMoveLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMoveLeftActionPerformed
// TODO adicione seu c�digo de manipula��o aqui:
        r.moveLeft();
        canvas.display();
    }//GEN-LAST:event_jButtonMoveLeftActionPerformed

    public void exibirVideo3D(String fileNameMovie3d) {
        // desabilitando botoes
        jButtonMoveLeft.setEnabled(false);
        jButtonMoveRight.setEnabled(false);
        jButtonMoveUp.setEnabled(false);
        jButtonMoveDown.setEnabled(false);
        jButtonRotXUp.setEnabled(false);
        jButtonRotXDown.setEnabled(false);
        jButtonRotYLeft.setEnabled(false);
        jButtonRotYRight.setEnabled(false);
        jButtonRotZmais.setEnabled(false);
        jButtonRotZmenos.setEnabled(false);
        jButtonVisualizarGrade.setEnabled(true);
        jButtonSaveImg.setEnabled(true);
        jButtonShowGrid.setEnabled(false);

        readingFileMovieFDTD3D rf = new readingFileMovieFDTD3D();
        try {
            rf.reading(fileNameMovie3d);

        } catch (FileNotFoundException ex) {
            Logger.getLogger(Visualizador.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Visualizador.class.getName()).log(Level.SEVERE, null, ex);
        }




    }
    
     public void exibirVideo2D(String fileNameMovie2d) {
        // desabilitando botoes
        jButtonMoveLeft.setEnabled(false);
        jButtonMoveRight.setEnabled(false);
        jButtonMoveUp.setEnabled(false);
        jButtonMoveDown.setEnabled(false);
        jButtonRotXUp.setEnabled(false);
        jButtonRotXDown.setEnabled(false);
        jButtonRotYLeft.setEnabled(false);
        jButtonRotYRight.setEnabled(false);
        jButtonRotZmais.setEnabled(false);
        jButtonRotZmenos.setEnabled(false);
        jButtonVisualizarGrade.setEnabled(true);
        jButtonSaveImg.setEnabled(true);
        jButtonShowGrid.setEnabled(false);

        readingFileMovieFDTD2D rf = new readingFileMovieFDTD2D();
        try {
            rf.reading(fileNameMovie2d);

        } catch (FileNotFoundException ex) {
            Logger.getLogger(Visualizador.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Visualizador.class.getName()).log(Level.SEVERE, null, ex);
        }




    }

    public void exibirGraficoTempo(String fileName, String legendaX, String legendaY) {

        // desabilitando botoes
        jButtonMoveLeft.setEnabled(false);
        jButtonMoveRight.setEnabled(false);
        jButtonMoveUp.setEnabled(false);
        jButtonMoveDown.setEnabled(false);
        jButtonRotXUp.setEnabled(false);
        jButtonRotXDown.setEnabled(false);
        jButtonRotYLeft.setEnabled(false);
        jButtonRotYRight.setEnabled(false);
        jButtonRotZmais.setEnabled(false);
        jButtonRotZmenos.setEnabled(false);
        jButtonVisualizarGrade.setEnabled(true);
        jButtonSaveImg.setEnabled(true);
        jButtonShowGrid.setEnabled(true);
//        jMenuItemConfigurarGrid.setEnabled(true);
//        jMenuItemGrid.setEnabled(true);


        // Lendo dados do arquivo escolhido
        try {

            r = new Renderizador();
            canvas = new GLCanvas();
            canvas.setPreferredSize(new Dimension(300, 400));
            r.setGLCanvas(canvas);
            canvas.addGLEventListener(r);
            // Adiciona a variavel canvas ao Panel
            jScrollPane1.setViewportView(canvas);
            canvas.display();

            readingFileFftGraph rf;
            rf = new readingFileFftGraph(fileName);
            jTAStatus.append("\n Arquivo: " + fileName + " carregado.");
            System.out.println("arquivo lido");

            // Jogando os dados na tela do Renderizador
            r.setStatusGrid(false);
            r.setVectorGraphFFT(rf.getvAmp(), rf.getvTempo(), rf.getYMax(), rf.getYMin());
            r.setLegendaEixoX(legendaX);
            r.setLegendaEixoY(legendaY);
            canvas.display();
        //jMenuItemSalvarGrafico.setEnabled(true);


        } catch (Exception e) {
            System.out.println("Exception: " + e);
        } catch (Error err) {
            System.out.println("Error: " + err);
        }



    }

    public void exibirGraficoAreaSAR(String fileName, String legendaX, String legendaY) {

        // desabilitando botoes
        jButtonMoveLeft.setEnabled(true);
        jButtonMoveRight.setEnabled(true);
        jButtonMoveUp.setEnabled(true);
        jButtonMoveDown.setEnabled(true);
        jButtonRotXUp.setEnabled(true);
        jButtonRotXDown.setEnabled(true);
        jButtonRotYLeft.setEnabled(true);
        jButtonRotYRight.setEnabled(true);
        jButtonRotZmais.setEnabled(true);
        jButtonRotZmenos.setEnabled(true);
        jButtonVisualizarGrade.setEnabled(false);
        jButtonSaveImg.setEnabled(true);
        jButtonShowGrid.setEnabled(false);
        jButtonLupaMais.setEnabled(true);
        jButtonLupaMenos.setEnabled(true);
//        jMenuItemConfigurarGrid.setEnabled(true);
//        jMenuItemGrid.setEnabled(true);


        // Lendo dados do arquivo escolhido
        try {

            r = new Renderizador();
            canvas = new GLCanvas();
            canvas.setPreferredSize(new Dimension(300, 300));
            r.setGLCanvas(canvas);
            canvas.addGLEventListener(r);
            // Adiciona a variavel canvas ao Panel
            jScrollPane1.setViewportView(canvas);
           
            readingFileAreaSAR areaSar = new readingFileAreaSAR();
            jTAStatus.append("\n Arquivo: " + fileName + " carregado.");

            // Jogando os dados na tela do Renderizador
            r.setVetorElementos(areaSar.reading(fileName));
            r.setStatusGrid(false);
           
            r.setLegendaEixoX(legendaX);
            r.setLegendaEixoY(legendaY);
            r.setPerspectiveAreaSAR();
            r.setRangeMaiorMenorCampo(areaSar.getRange(), areaSar.getMaiorCampo(), areaSar.getMenorcampo());
            r.setStatusAreaSAR(true);
            
           
            canvas.display();
        //jMenuItemSalvarGrafico.setEnabled(true);


        } catch (Exception e) {
            System.out.println("Exception: " + e);
        } catch (Error err) {
            System.out.println("Error: " + err);
        }



    }

    private void girarZNegativoListener(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_girarZNegativoListener
        // button "Z-"
       // r.subRotacaoZ();
        canvas.display();
    }//GEN-LAST:event_girarZNegativoListener

    private void girarZPositivoListener(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_girarZPositivoListener
        // button "Z+"
       // r.addRotacaoZ();
        canvas.display();
    }//GEN-LAST:event_girarZPositivoListener

    private void girarYNegativoListener(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_girarYNegativoListener
        // button "Y-"
      //  r.subRotacaoY();
        canvas.display();
    }//GEN-LAST:event_girarYNegativoListener

    private void girarYPositivoListener(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_girarYPositivoListener
        // button "Y+"
      //  r.addRotacaoY();
        canvas.display();
    }//GEN-LAST:event_girarYPositivoListener

    private void girarXNegativoListener(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_girarXNegativoListener
        // button "X-"
       // r.subRotacaoZ();
        canvas.display();
    }//GEN-LAST:event_girarXNegativoListener

    private void girarXPositivoListener(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_girarXPositivoListener
        // button "X+"
       // r.addRotacaoX();
        canvas.display();
    }//GEN-LAST:event_girarXPositivoListener

    private void afastarListener(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_afastarListener
        // button "-"
       // r.subPosicaoZ();
        canvas.display();
    }//GEN-LAST:event_afastarListener

    private void aproximarListener(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aproximarListener
        // button "+"
       // r.addPosicaoZ();
        canvas.display();
    }//GEN-LAST:event_aproximarListener

private void jCkVisivelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCkVisivelActionPerformed
// TODO add your handling code here:

    if (jCkVisivel.isSelected()) {
        r.setGridFFT(true);
    } else {
        r.setGridFFT(false);
    }
    canvas.display();
}//GEN-LAST:event_jCkVisivelActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonCancelarGrade;
    private javax.swing.JButton jButtonConfirmarGrade;
    private javax.swing.JButton jButtonLupaMais;
    private javax.swing.JButton jButtonLupaMenos;
    private javax.swing.JButton jButtonMoveDown;
    private javax.swing.JButton jButtonMoveLeft;
    private javax.swing.JButton jButtonMoveRight;
    private javax.swing.JButton jButtonMoveUp;
    private javax.swing.JButton jButtonRotXDown;
    private javax.swing.JButton jButtonRotXUp;
    private javax.swing.JButton jButtonRotYLeft;
    private javax.swing.JButton jButtonRotYRight;
    private javax.swing.JButton jButtonRotZmais;
    private javax.swing.JButton jButtonRotZmenos;
    private javax.swing.JButton jButtonSaveImg;
    private javax.swing.JButton jButtonShowGrid;
    private javax.swing.JButton jButtonVisualizarGrade;
    private javax.swing.JCheckBox jCkVisivel;
    private javax.swing.JDialog jDialogConfigGrade;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSpinner jSqtdX;
    private javax.swing.JSpinner jSqtdY;
    private javax.swing.JTextArea jTAStatus;
    private javax.swing.JToolBar jToolBar1;
    // End of variables declaration//GEN-END:variables
    // Variavel GLCanvas que substitui a variavel Canvas
    private GLCanvas canvas;
    private Renderizador r = new Renderizador();
    GLAutoDrawable a;
    private String name;
    int qtdXantes;
    int qtdYantes;
}
